package exchange;

public class B {

	public void doIt(final A a) {
		int max = 10;
		for (int i = 1; i < max; i++) {
			double dollars = a.getValueInDollars();
			a.setValueInDollars(dollars + i);
			try {
				Thread.sleep(1);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			a.setValueInDollars(a.getValueInDollars() - i);
		}
	}

	public void doItOnAnotherThread(final A a) {
		Thread th = new Thread() {
			public void run() {
				// System.out.println("New thread : I'm alive!");
				doIt(a);
			}
		};
		th.start();
	}
}
